package org.wlgzs.shop.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wlgzs.shop.bean.PostMoney;
import org.wlgzs.shop.bean.PostMoneyExample;
import org.wlgzs.shop.dao.PostMoneyMapper;
import org.wlgzs.shop.service.IPostMoneyService;

import java.util.List;

/**
 * @Author: Ben
 * @Date: 2019/5/22 21:31
 * @Project org.wlgzs.shop
 */
@Service(value = "PostMoney")
public class PostMoneyServiceImpl implements IPostMoneyService {

    @Autowired
    PostMoneyMapper postMoneyMapper;

    /**
     * 增加邮费信息
     * @param postMoney
     * @return int
     */
    @Override
    public int insertPostMoneyIPostMoneyService(PostMoney postMoney) {
        return postMoneyMapper.insert(postMoney);
    }

    /**
     * 根据邮费id删除邮费信息
     * @param postId
     * @return int
     */
    @Override
    public int deletePostMoneyIPostMoneyService(int postId) {
        return postMoneyMapper.deleteByPrimaryKey(postId);
    }

    /**
     * 根据邮费id更改邮费信息
     * @param postMoney
     * @return int
     */
    @Override
    public int updatePostMoneyIPostMoneyService(PostMoney postMoney) {
        return postMoneyMapper.updateByPrimaryKeySelective(postMoney);
    }

    /**
     *根据邮费id查询邮费信息
     * @param postId
     * @return List<PostMoney>
     */
    @Override
    public List<PostMoney> selectPostMoneyIPostMoneyService(int postId) {
        PostMoneyExample postMoneyExample=new PostMoneyExample();
        PostMoneyExample.Criteria criteria=postMoneyExample.createCriteria();
        criteria.andPostIdEqualTo(postId);
        List<PostMoney> postMoneyList=postMoneyMapper.selectByExample(postMoneyExample);
        return postMoneyList;
    }
}
